﻿using System;
using System.Globalization;
using System.Linq;
using System.Web.UI;
using Microsoft.SharePoint;
using SPSocialTagCounters.Helpers;

namespace SPSocialTagCounters.ControlTemplates.SPSocialTagCounters
{
    public partial class Tags : UserControl
    {
        private SPSocialTagCounter socialTagCounter;

        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            socialTagCounter = SocialHelper.GetTags(this.Page.Request.Url);

            if (socialTagCounter != null)
            {
                litJS.Text   = string.Format("{0}", SPPropertyBagHelper.GetPropertyValue(SPContext.Current.Site.RootWeb, SPPropertyBagHelper.JSKey));
                litCSS.Text  = string.Format("<style>{0}</style>", SPPropertyBagHelper.GetPropertyValue(SPContext.Current.Site.RootWeb, SPPropertyBagHelper.StyleKey));
                litHTML.Text = string.Format(SPPropertyBagHelper.GetPropertyValue(SPContext.Current.Site.RootWeb, SPPropertyBagHelper.HTMLKey),
                                             socialTagCounter.Tags.ToString(CultureInfo.InvariantCulture),
                                             socialTagCounter.TagsList,
                                             socialTagCounter.Likes.ToString(CultureInfo.InvariantCulture),
                                             socialTagCounter.LikesList);
            }
        }


    }
}
